/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bombercloud.client;

import bombercloud.commons.BlocoQuebra;
import bombercloud.commons.Request;
import bombercloud.commons.Response;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Delano
 */
public class ThreadBomba extends Thread {

    ObjectInputStream inputStream;
    ObjectOutputStream outputStream;
    Socket socket;
    BlocoQuebra blocoQuebra;

    public ThreadBomba(Socket socket1, ObjectOutputStream objectOutputStream1, BlocoQuebra bq) {
        socket = socket1;
        outputStream = objectOutputStream1;
        blocoQuebra = bq;
    }

    public void run() {
        try {
            sleep(5000);
            Request request = new Request();
            request.setType(request.REQUEST_TYPE_DELETE_BOMBA);
            request.setParam3(blocoQuebra);
            executeRequest(request);

        } catch (InterruptedException ex) {
            Logger.getLogger(ThreadBomba.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public synchronized Response executeRequest(Request request) {
        Response response = null;
        try {
            outputStream.writeObject(request);
            outputStream.flush();
        } catch (IOException ex) {
            System.out.println(ex.getMessage());
        }
        return response;
    }
}
